package cn.itcast.controller.map;


import cn.itcast.base.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

//百度地图的demo

@SuppressWarnings("all")
@RequestMapping(value = "/baidu")
@Controller
public class MapController extends BaseController {


    @RequestMapping(value = "/map.do")
    public String demo() {


     return "map/demo";
    }

    @RequestMapping(value = "/maps.do")
    public String demo(String city) {

        Map<String, String> map = LocationUtil.getLatitude(city);
        if (null != map) {
            System.out.println(map.get("lng"));
            String lng = map.get("lng");
            String lat = map.get("lat");
            System.out.println(map.get("lat"));
            request.setAttribute("lng",lng);
            request.setAttribute("lat",lat);
        }

        return "map/demo03";
    }



    @RequestMapping(value = "/map2.do")
    public String demo1() {


        return "map/demo04";
    }



    @RequestMapping(value = "/map2s.do")
    public String demo(String start,String end) {

        Map<String, String> map = LocationUtil.getLatitude(start);
        Map<String, String> map1 = LocationUtil.getLatitude(end);
        if (null != map) {
            System.out.println(map.get("lng"));
            String lng = map.get("lng");
            String lat = map.get("lat");
            System.out.println(map.get("lat"));
            request.setAttribute("lng",lng);
            request.setAttribute("lat",lat);
        }
        if (null != map1) {
            System.out.println(map1.get("lng"));
            String lng2 = map1.get("lng");
            String lat2 = map1.get("lat");
            System.out.println(map1.get("lat"));
            request.setAttribute("lng2",lng2);
            request.setAttribute("lat2",lat2);
        }
           request.setAttribute("start",start);
           request.setAttribute("end",end);
            return "map/demo06";
    }
}
